package com.chen.pay.system.paysystem.controller;

import com.chen.pay.system.paysystem.entity.PayEntity;
import com.chen.pay.system.paysystem.service.PayService;
import com.chen.pay.system.paysystem.service.impl.PayServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 支付
 * @author :master
 */

@RestController
@RefreshScope
@RequestMapping("/pay")
public class PayController {

    @Autowired
    private PayService service;

    @Value("${pay.status}")
    private String payStatus;


    @RequestMapping("/gatStatus")
    public String gatStatus() {
        return payStatus;
    }

    @RequestMapping("/addPay")
    public String addPay(@RequestBody PayEntity payEntity){
        try {
            service.addPay(payEntity);
            return "支付成功";
        }catch (Exception e) {
            return "支付失败";
        }
    }

    @RequestMapping("/updatePay")
    public String updatePay(@RequestBody PayEntity payEntity){
        try {
            service.updatePay(payEntity);
            return "支付成功";
        }catch (Exception e) {
            return "支付失败";
        }
    }
}
